home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
diskmags
/
0022-3.564
/
dmg-3451
/
data
/
50hz.dat
< prev
next >
Wrap
Text File
|
1987-04-21
|
7KB
|
136 lines
Hertz - The Mystery Explained.
Written by Wheee the fibble.
Ok, anyone who has ever looked at an assembly demo like The
European Demos or Mindbomb, or even Enchanted Lands I suppose,
will have been rather immpressed by the speed and smoothness of
the graphics. Most STOS coders I've spoken to have put this down
to the rather mysterious reason that it was written in ASSEMBLY.
Nothing to do with good programming or anything, just the mere
fact that it was written in ASSEMBLY made it fast and smooth. The
reason the same people give for their demo screens graphics flicking
and jerking around the screen is just that it was written in STOS,
and of course, therefore couldn't ever hope to go that fast. Now,
most people reading this will, I hope, be thinking "Phew, how
silly - I know that isn't the reason." But, how many of us can
claim never to have blamed STOS for our screens/programmes looking
crap? Not many I suspect. It must be said of course that STOS is
responsable for many problems and errors, but there we go, can't
have everything...
Well, if you are still wondering why it is that assembly
screens look so smooth I'll just explain...
The TV/Monitor you're looking at has it's picture updated 50
times a second (or 60 if it's a colour monitor, or 70 if it's
mono). The screen is drawn by a little "gun" which fire electrons
at the screen, making it glow the colour of the picture at that
point on the screen. The gun moves from the top left of the
picture to the bottom right, line by line. The time it takes for
the gun to draw 1 line from left to right is called a "Horizontal
blank", and the time for the whole screen to be drawn is a
"Verticle blank". Incedently, there is also the time taken for
the gun to jump from the bottom right back to the top left again,
but I'll ignore that for the moment...
Now, in order to get your screens looking perfectly smooth
(like (almost) all the screens in the "Ever-So-Wonderful" Better
Than Life Demo) you have to get all of your graphics, music and
sprite operations completed before the gun reaches the bottom
right of the screen, ie, you must get your program to do
everything in under 1/50th of a second! Almost all assembly
screens do this, that is why the graphics move so smoothly - they
are exactly in sync with the vertical blank so that every time the
gun goes back to the top left of the screen, the graphics have
been moved to their next positions and so appear to move really
smoothly... STOS screens on the other hand usually are not in
sync with the vertical blank, thus they seem to flicker or wobble
around the screen.
The major cause of this is trying to get STOS to do too much
of the work. There are many STOS demo screens where people have
tried to get as much stuff as there is on assembly demos and end
up with a jerky mess. There are many ways to stop this sort of
thing happening. One is not to use STOS sprites - they're crap.
Try this little test program for instance which will show you the
difference between STOS sprites and screen copy sprites...
10 timer=0:forT=1 to 100:sprite 1,15,0,1:nextT:T=timer:?T
20 timer=0:forT=1 to 100:screencopy physic,0,0,16,16toback,0,0:
nextT:T=timer:?T
It assumes that the sprite you're using is 16x16, but it should
still show a rather major difference between the two methods.
There are many other ways of saving time in your programs, too
many to go into here, but safe to say that there are many, many
ways to get round STOS's problems...
Now, inside your main loop there should be a line something
like this:-
100 screen swap : waitvbl
This will swap the addresses of the logical and physical
screens so that the whole screen is drawn at once, and the wait
vbl will wait for the next vertical blank to occur. If you want
your screen to go at 50 hertz (in sync with the vbl) you will have
to change the line to read:-
100 screen swap : doke $ffff8240,$777 : doke $ffff8240,$000 : wait vbl
This, when run, will put a little raster line on the screen
which will show you where the electron gun has reached after doing
all of your graphics and music. The amount of space left
underneath it is how much processor time you have left to do more
things in your screen! Be careful though, the line will come out
of the top of the screen again if you have used up all of the
proccessor time (or more), so be careful that the routine you
think is really fast, is in fact really slow... It's best to
build up your screen so that you can see how much time you have
left, and how much each new part is taking up. Ideally,
everything should be complete before the raster hits the bottom of
the screen, if this is so then your screen can be said to be
running at 50 hertz and, should, look very smooth! If the raster
has gone out of the bottom of the screen and come in the top again
then your screen is said to be running at 25 hertz. No releasable
demoscreen should ever be at less the 25 hertz, and even the 25
hertz ones are very unusual. Run this little program to
demonstrate what I mean (use + and - to change the number of
dots), it should be on the disk called "hztest.bas":-
10 key off : curs off : auto back off : hide on : mode 0
20 MX=1 : X=1
30 logic=back
40 repeat
45 for T=1 to MX : plot OLDX,T*4,0 : next T
50 for T=1 to MX : plot X,T*4,1 : next T : OLDX=X : X=X mod 319+1
60 screen swap : doke $FFFF8240,$7 : doke $FF8240,$0 : wait vbl
70 G$=inkey$
80 until (G$="+") or (G$="-") or (G$=" ")
90 if G$=" " then default : end
100 if G$="-" and MX>1 then dec MX
110 if G$="+" and MX<49 then inc MX
120 clear key : goto 40
If you watch the raster, the points should look nice and
smooth until it goes out of the bottom and comes in the top
again. That's the difference between 50 and 25 hertz! So, if you
want your screens to look as smooth as those in assembly demos or
those in the Better Than Life demo, just make sure that your
screen does everything before the line goes out of the bottom of
the screen...
Incedently, if you have a colour monitor and your running in
60 hertz, you do realise that this means you have to goet all of
your grphics/music operations completed within 1/60th of a
second??? That's why you see many programs talking about
"Forcing" 50 hertz. In order to do this in STOS you'll have to
muck around with the value in location $ffff820a, try this little
routine to find out which values to put in:-
frequency:f1=peek($ffff820a):frequency:f2=peek($ffff820a):?f1,f2
Well, I hope you understood all that, and I hope to see some
more smooth screens in future... If you want to get in touch,
call me at (0389) 64820 and ask for Billy...
Bye then...
note from editor: 60 hertz isn't as painful as ten shap lashes
with ten foot steel rod.